package de.lns.entities.effect;

import de.lns.entities.mobs.Mob;
import de.lns.tick.UpdateThread;
/**
 * 
 * @author Jascha
 *
 */
public class ModifierEffect extends TimedEffect {
	
	public static final boolean flat=false;
	public static final boolean relative=true;

	protected int modification;
	protected double multiplier;
	protected boolean type;
	protected Mob mob;
	
	/**
	 * 
	 * @param entity The Mob this effect should be applied on.
	 * @param time The time this effect should last in ms.
	 * @param modification	The modification of this effect (try modification.variable).
	 * @param type The modification type of this effect (flat or relative)
	 * @param multiplier The multiplier of this effect.
	 */
	public ModifierEffect(Effectable entity, int time, int modification, boolean type, double multiplier) {
		super(entity,time);
		this.modification=modification;
		this.multiplier = multiplier;
		mob = (Mob) entity;
		this.type = type;
		if(!type)
			mob.setModificationflat(modification, multiplier);
		else if(type)
			mob.setModificationrelative(modification, multiplier);
		
		
	}
	
	@Override
	/**
	 * Before this effect get removed, it removes it own multiplier from the mob.
	 */
	public void setEntity(Effectable entity){
		if(!type)
			mob.setModificationflat(modification, multiplier);
		else if(type)
			mob.setModificationrelative(modification, multiplier);
	}
	@Override
	/**
	 * Before this effect get removed, it removes it own multiplier from the mob.
	 */
	public void update(){
		super.update();
	}
	public void remove(){
		if(!type)
			mob.setModificationflat(modification, -multiplier);
		else if(type){
			mob.setModificationrelative(modification, -multiplier);
		}
	}

}
